<!--意见反馈页面-->
<style lang="less">
</style>

<template>
  <i-col span="24">
    <Card :bordered="false">
      <p slot="title"
         class="white">待办事项 > <span class="select-font">意见反馈</span>
      </p>
    </Card>
    <Table :data="optionData"
           :columns="optionColumns"
           stripe></Table>
    <Page class="pull-right"
          :total="Page.total"
          :current="Page.current"
          :page-size="Page.pageSize"
          size="small"
          show-total
          @on-change="changePage"></Page>
  </i-col>
</template>

<script>
import { timeFilter } from 'common/js/util';
import { ajaxPost } from 'global/axios';
import storage from 'good-storage';
export default {
  data() {
    return {
      optionUrlList: '/bus/advice/list',
      optionData: [],
      optionColumns: [
        {
          title: '名字',
          align: 'center',
          key: 'realname',
        },
        {
          title: '电话',
          align: 'center',
          key: 'phone',
        },
        {
          title: '填写时间',
          align: 'center',
          key: 'date_time',
        },
        {
          title: '建议内容',
          align: 'center',
          key: 'content',
        },
      ],
      Page: {
        current: 1,
        pageSize: 13,
        total: 0,
      },
      actionPage: '1',
    };
  },
  methods: {
    getTableData(page) {
      let that = this;
      let params = {
        data: {
          pageSize: this.Page.pageSize,
          page: 1,
          order: { _id: -1 },
        },
        url: this.optionUrlList,
        token: storage.session.get('token'),
        success: res => {
          that.optionData = res.data.result.result;
          that.optionData.map(item => {
            item.date_time = timeFilter(
              new Date(item.date_time),
              'yyyy年MM月dd日'
            ).substr(0, 11);
          });
          that.Page.total = res.data.result.totalSize;
        },
      };
      if (typeof page === 'string' || typeof page === 'number') {
        params.data.page = parseInt(page);
      }
      ajaxPost(params);
    },
    changePage(page) {
      this.getTableData(page);
      this.actionPage = page;
    },
  },
  mounted() {
    this.getTableData();
  },
};
</script>
